package com.design.consumer.p02;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class TestProduce {

	public static void main(String[] args) {

		Storage storage = new Storage();

		// 生产者对象
		Producer p1 = new Producer(storage);
		Producer p2 = new Producer(storage);
		Producer p3 = new Producer(storage);
		Producer p4 = new Producer(storage);
		Producer p5 = new Producer(storage);
		Producer p6 = new Producer(storage);

		p1.setNum(1);
		p2.setNum(3);
		p3.setNum(2);
		p4.setNum(4);
		p5.setNum(5);
		p6.setNum(8);

		// 消费者对象
		Consumer c1 = new Consumer(storage);
		Consumer c2 = new Consumer(storage);
		Consumer c3 = new Consumer(storage);

		c1.setNum(7);
		c2.setNum(3);
		c3.setNum(6);

		ExecutorService pool = Executors.newFixedThreadPool(10);
		pool.submit(p1);
		pool.submit(p2);
		pool.submit(p3);

		pool.submit(c1);
		pool.submit(c2);
	}

}
